Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix infinite loop on redirect to file #184

Closed
wants to merge 5 commits into from

Conversation

mrkane27
Copy link

@mrkane27 mrkane27 commented Jan 7, 2016

@dnfclas
Copy link

dnfclas commented Jan 7, 2016

Hi @mrkane27, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!

This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. Real humans will now evaluate your PR.

TTYL, DNFBOT;

@yishaigalatzer yishaigalatzer changed the title [1893] fix infinite loop on redirect to file fix infinite loop on redirect to file Jan 7, 2016
@yishaigalatzer
Copy link
Contributor

Sorry - Commented on the issue instead of the PR.

Thanks for this cool fix. We would love to take it after adding a failing test in the current code, that gets fixed by this change.

@mrkane27
Copy link
Author

mrkane27 commented Jan 7, 2016

Thanks for replying!

As far as I can tell, the issue only happens on Linux and Mac, using Mono.
Do you run tests on any of those? If yes, could you point me to where I should add a test? -- I've never contributed to this repository before.

@yishaigalatzer
Copy link
Contributor

Ah - Cool.

We are not yet running tests on mac and linux regularly (but in fact that is what half the team is doing this week, making it all happen for core clr).

Lets do this for now

  1. Add a comment that this only happens on mono
  2. We will try that with the new nuget.commandline.xplat package (to make sure it doesn't repeat there)
  3. Add a follow up test, once we have the linux tests passing properly (we are still tracking a few tens of test failures)

[Fact]
public void TestConsoleWindowWidthNotZero()
{
Assert.NotEqual(0, new NuGet.Common.Console().WindowWidth);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test will only be relevant if someone runs the tests on Linux, with output redirect. I tried messing around with System.Console.SetOut() and the like at runtime, but Mono does some initialization before that, so it won't apply.

@mrkane27
Copy link
Author

mrkane27 commented Jan 8, 2016

A different take might be to use System.Console.IsOutputRedirected and default to e.g. a width of 80, which would make sense for file output -- but that might be overkill for this fix.

@yishaigalatzer
Copy link
Contributor

I like this new idea better. Lets update to it or does not sound like an overkill.

We are running tests on Linux on a CI regularly starting from this week.

@mrkane27
Copy link
Author

mrkane27 commented Jan 8, 2016

I thought about this for a bit more, and it might not actually work. For example, if you do nuget ... | cat, you might still want it formatted for the terminal. I don't think there's a reliable way to determine whether the final output is into a file. What do you think?

I've also run some tests on how Console behaves on .NET and Mono, if you want to take a look.

@yishaigalatzer
Copy link
Contributor

I think the key is to unblock the hang. In general we are moving NuGet off mono and moving it gradually to coreCLR on unix (see nuget.commandline.xplat package), so coming up with something reasonable (like your suggestion of 80 chars) might be good enough. And then on coreCLR we can try to get things fixed.

@mrkane27
Copy link
Author

Is this current state what you had in mind?

@deepakaravindr deepakaravindr self-assigned this Feb 5, 2016
@deepakaravindr
Copy link
Contributor

@mrkane27, Thanks for the tests on how Console behaves on .NET and Mono. I have checked it out. Your fix looks good to me too. I have merged it with 6afc0ac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants